<?php

namespace App\Http\Models\Spa\Admin;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
// use Illuminate\Foundation\Auth\User as Authenticatable;
// use Illuminate\Notifications\Notifiable;
use Carbon\Carbon;

class Article extends \Illuminate\Database\Eloquent\Model
{
    // use Notifiable;

    public $incrementing = false;

    // /**
    //  * The attributes that are mass assignable.
    //  *
    //  * @var array
    //  */
    // protected $fillable = [
    //     'id',
    // ];

    // /**
    //  * The attributes that should be hidden for arrays.
    //  *
    //  * @var array
    //  */
    // protected $hidden = [
    //     'so_title',
    // ];

    // /**
    //  * The attributes that should be cast to native types.
    //  *
    //  * @var array
    //  */
    // protected $casts = [
    //     'email_verified_at' => 'datetime',
    // ];
    // 
    // protected $casts = [
    //     'created_at' => 'datetime:Y-m-d H:i:s',
    //     'updated_at' => 'datetime:Y-m-d H:i:s',
    // ];
    // 
    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    // 模型类属性与数据表字段的映射
    // protected $maps = [
    //   'title' => 'so_title',
    //   'status' => 'so_status'
    // ];

    /**
     * 将资源转换成数组。
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray()
    {
        return [
            'id' => $this->id,
            'title' => $this->so_title,
            'content' => $this->so_content,
            // 'created_at' => $this->created_at,
            'created_at' => Carbon::parse($this->created_at)->toDateTimeString(),
            'updated_at' => $this->updated_at,
        ];
    }
}
